package TestSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/cookies1")
public class Testcookies extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("coolie1");
        Cookie cookie = new Cookie("hello", "HY");
        Cookie cookie1 = new Cookie("hello1", "HY1");
        Cookie cookie2 = new Cookie("hello2", "HY2");

        cookie.setMaxAge(60);
        cookie1.setMaxAge(60);
        cookie2.setMaxAge(60);

        resp.addCookie(cookie);
        resp.addCookie(cookie1);
        resp.addCookie(cookie2);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
